<?php

namespace app\admin\validate;

use think\Validate;

class ConfigValidate extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */
	protected $rule = [
	    "name"  => "require|regex:/^\w+$/|unique:config",
        //"name"  => ["require","regex"=>"/^\w+$/","unique"=>"config"],
        "title" => "require",
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */
    protected $message = [
        "name.require"  => "标识不能为空",
        "name.regex"    => "标识必须是数字字母或下划线",
        "name.unique"   => "标识已存在",
        "title.require" => "名称不能为空",
    ];


    //修改场景
    public function sceneUpdate(){
        return $this->only(['password'])
            ->remove('password', 'require');
    }

}
